using System.Security.Principal;
using System.Web;
using System.Web.Security;
using MvcMall.Core.Contacts.Services;

namespace MvcMall.Data.Services
{
    public class IdentityService : IIdentityService
    {
        public void SignIn(string userName, bool createPersistentCookie)
        {
            FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
        }

        public void SignOut()
        {
            FormsAuthentication.SignOut();
        }

        public bool IsSignedIn()
        {
            return HttpContext.Current.User.Identity.IsAuthenticated;
        }

        public IIdentity GetCurrentIdentity()
        {
            return HttpContext.Current.User.Identity;
        }
    }
}